package com.xbongbong.sys.enums;

import lombok.Getter;

import java.util.Objects;

/**
 * 钉钉连接器动作，增(add)改(update)删(delete)
 */
@Getter
public enum ConnectorActionEnum {
    /**
     *
     */
    ADD("add","增"),
    UPDATE("update","改"),
    DELETE("delete","删"),
    UNKNOWN("unknown","unknown"),
    ;

    private String alias;

    private String name;

    ConnectorActionEnum(String alias, String name) {
        this.alias = alias;
        this.name = name;
    }

    /**
     * 根据alias获取枚举
     * @return
     */
    public static ConnectorActionEnum getByAlias(String alias) {
        if (alias == null) {
            return UNKNOWN;
        }
        for (ConnectorActionEnum cache : values()) {
            if (Objects.equals(cache.getAlias(), alias)) {
                return cache;
            }
        }
        return UNKNOWN;
    }
}
